// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
var EnumProp = require('./Enum/EnumProp');
cc.Class(
{
    extends: cc.Component,

    properties:
    {
        lbGold:
        {
            default: null,
            type: cc.Label,
            displayName: '金币数量'
        },
        lbDiamond:
        {
            default: null,
            type: cc.Label,
            displayName: '钻石数量'
        }
    },

    addGold(_cnt)
    {
        if (null == this.goldCnt)
        {
            this.goldCnt = 0;
        }
        this.goldCnt += _cnt;
        if (null != this.lbGold)
        {
            this.lbGold.string = this.goldCnt;
        }

    },
    addDiamond(_cnt)
    {
        if (null == this.diamondCnt)
        {
            this.diamondCnt = 0;
        }
        this.diamondCnt += _cnt;

        if (null != this.lbDiamond)
        {
            this.lbDiamond.string = this.diamondCnt;
        }
    },

    addPropCnt(_enumProp, _cnt)
    {
        if (EnumProp.GOLD == _enumProp)
        {
            this.addGold(_cnt)
        }
        else if (EnumProp.DIAMOND == _enumProp)
        {
            this.addDiamond(_cnt)
        }
    }
});